<?php
if (!isset($_SESSION)) { session_start(); }
  include_once('../includes/fk_php/funciones.php');
  include_once('../includes/fk_php/Connections/connection.php');
    	
$menu = $_POST['node'];
$usuario = $_SESSION["SUSUARIO"];
$arr = array();

if (!is_numeric($menu)){
  $consultaSQL = ("CALL SP_MENUS_USER('$usuario')");
  $menus = $connection->query($consultaSQL);
   while($obj = $menus->fetch_row()){
     // $arr[] = $obj;
	  $arr[] = array('text'=>$obj[0], 'id'=>$obj[1], 'url'=>$obj[2]);
   }
} else {
  $consultaSQL = ("CALL SP_SUBMENUS_USER('$usuario',$menu)");
  $menus = $connection->query($consultaSQL);
   while($obj = $menus->fetch_row()){
     // $arr[] = $obj;
	  $arr[] = array('text'=>$obj[0], 'id'=>$obj[2], 'leaf'=>$obj[3]);
   }
}



echo json_encode($arr);
?>